Skip to content

Expand altrep in assign#5401

Merged
MichaelChirico merged 9 commits into
masterfrom
expand_ALTREP_in_assign
Jun 27, 2025
Merged

Expand altrep in assign#5401
MichaelChirico merged 9 commits into
masterfrom
expand_ALTREP_in_assign

Conversation

@tlapak
Copy link
Copy Markdown
Contributor

@tlapak tlapak commented Jun 3, 2022

Closes #5400

Note that I modified test 754.5 (now 754.05) because the character conversion (now tested in 754.07 and 754.08) gets deferred which results in the same behaviour as in the report, while as.numeric doesn't get deferred.

Tests 754.05, 754.07 and 754.09 depend on ALTREP behaviour of R and could break if that changes without data.table being broken, e.g. if as.numeric gets deferred at some point in the future, the test will break but everything will still work correctly.

@jangorecki jangorecki added this to the 1.14.3 milestone Jun 16, 2022
@jangorecki jangorecki modified the milestones: 1.14.3, 1.14.5 Jul 19, 2022
@jangorecki jangorecki modified the milestones: 1.14.11, 1.15.1 Oct 29, 2023
Comment thread NEWS.md Outdated

1. `unique()` returns a copy the case when `nrows(x) <= 1` instead of a mutable alias, [#5932](https://github.com/Rdatatable/data.table/pull/5932). This is consistent with existing `unique()` behavior when the input has no duplicates but more than one row. Thanks to @brookslogan for the report and @dshemetov for the fix.

2. `data.table` did not always expand ALTREP columns when assigning a full column by reference. This could result in the target column getting modified unintentionally if the next call to the data.table was a modification by reference of the source column. E.g. in `DT[, b := as.character(a)]` the string conversion gets deferred and subsequent modification of column `a` would also modify column `b`, [#5400](https://github.com/Rdatatable/data.table/issues/5400). Thanks to @aquasync for the report and Václav Tlapák for the PR.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be more specific? "did not always", well, when?

Trying to put myself in the shoes of a user scanning the NEWS for bugs that might affect me, this one might seem "scary" without more clarity.

Comment thread inst/tests/tests.Rraw
Comment thread src/assign.c Outdated
(TYPEOF(values)==VECSXP && i>LENGTH(values)-1) || // recycled RHS would have columns pointing to others, #185.
(TYPEOF(values)!=VECSXP && i>0) // assigning the same values to a second column. Have to ensure a copy #2540
(TYPEOF(values)!=VECSXP && i>0) || // assigning the same values to a second column. Have to ensure a copy #2540
ALTREP(thisvalue)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a comment here on why this test exists would be appropriate IMO

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.69%. Comparing base (037bc89) to head (6d257f5).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5401   +/-   ##
=======================================
  Coverage   98.69%   98.69%           
=======================================
  Files          79       79           
  Lines       14678    14679    +1     
=======================================
+ Hits        14487    14488    +1     
  Misses        191      191           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MichaelChirico MichaelChirico modified the milestones: 1.16.0, 1.17.0 Jul 10, 2024
@MichaelChirico
Copy link
Copy Markdown
Member

Hi @tlapak, would you like to revisit this PR for 1.17.0 (#6616)?

@MichaelChirico MichaelChirico modified the milestones: 1.17.0, 1.18.0 Jan 6, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 27, 2025

No obvious timing issues in HEAD=expand_ALTREP_in_assign
Comparison Plot

Generated via commit 6777191

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 5 minutes and 8 seconds
Installing different package versions 9 minutes and 19 seconds
Running and plotting the test cases 2 minutes and 28 seconds

Copy link
Copy Markdown
Member

@MichaelChirico MichaelChirico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! I'm not reproducing the testFun() giving ALTREP locally, but it still passes the test...

@MichaelChirico MichaelChirico merged commit ad2e22d into master Jun 27, 2025
10 checks passed
@MichaelChirico MichaelChirico deleted the expand_ALTREP_in_assign branch June 27, 2025 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aliasing issue with := affecting a different column

3 participants